<?php
	header("content-type:text/html;charset=utf8");
	$pdo = new PDO("mysql:host=127.0.0.1;dbname=exam",'root','root');
	$city =$_POST['city'];
	$selectsql = "select * from wea where city ='city'";
	$res = $pdo->query($selectsql)->fetchALL(PDO::FETCH_ASSOC);
	if(!$res){
		$url = "";
		$data = file_get_contents($url);
		$data = json_decode($data,true);
		$res = $data['result'];
		foreach ($res as $value) {
			$week = $value['week'];
			$city = $value['citynm'];
			$temp_high =$value['temp_high'];
			$temp_low = $value['temp_low'];
			$temperature = $value['temperature'];
			$sql = "insert into wea values('','$city','$week','$temp_high','$temp_low','$temperature')";
			$pdo ->exec($sql);

		}
	}
	echo json_encode($res);
